package two_shang._10_26;

public class ArrTest {
    public static int div(int a, int b) throws Exception {
        if (b == 0) throw new Exception("除数为零");
        return a / b;
    }

    public static void main(String[] args) {
        int x = 0;
        try {
            x = div(10, 1);
            System.out.println(x);
        } catch (Exception e) {
            System.out.println("捕获的异常是：" + e.getMessage());
        }

        try {
            x = div(10, 0);
            System.out.println(x);
        } catch (Exception e) {
            System.out.println("捕获的异常是：" + e.getMessage());
        }
    }
}


